//
//  ViewController.m
//  练习
//
//  Created by dllo on 16/6/4.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    [self creadS7ubViews];
    [self creatButtons];

    
}

-(void)creadS7ubViews{
    UIView *blueView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width/4,self.view.frame.size.height/4)];
    blueView.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blueView];
    UIView *blue1View = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/4 , self.view.frame.size.height/4, self.view.frame.size.width/4, self.view.frame.size.height/4)];
    blue1View.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blue1View];
    UIView *blue2View = [[UIView alloc]initWithFrame:CGRectMake( self.view.frame.size.width/4*2, self.view.frame.size.height/4*2, self.view.frame.size.width/4, self.view.frame.size.height/4)];
    blue2View.backgroundColor = [UIColor blueColor];
    [self.view addSubview:blue2View];
    UIView *blue3View = [[UIView alloc]initWithFrame:CGRectMake(self.view.frame.size.width/4*3,self.view.frame.size.height/4*3,self.view.frame.size.width/4,self.view.frame.size.height/4)];
    blue3View.backgroundColor = [UIColor blueColor];
   [self.view addSubview:blue3View];
   
}

-(void)creatButtons{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor greenColor];
    button.frame = CGRectMake(200, 200, 100, 100);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(changeCountAction:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)changeCountAction:(UIButton*)parbutton{
    int a = arc4random()%2;
    int c = arc4random()%2;
    int b = arc4random()%2;
    self.view.backgroundColor = [UIColor colorWithRed:a/2.0 green:b/2.0 blue:c/2.0 alpha:1];
    UIView *blueView =[[UIView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)];
    blueView.backgroundColor = [UIColor redColor];
    [self.view addSubview:blueView];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.backgroundColor = [UIColor greenColor];
    button.frame = CGRectMake(0, 200, 100, 100);
    [self.view addSubview:button];
    [button addTarget:self action:@selector(changCountAction:) forControlEvents:UIControlEventTouchUpInside];
}
    -(void)changCountAction:(UIButton*)parbutton{
    self.view.backgroundColor =[UIColor blackColor];
    UIView *black =[[UIView alloc]initWithFrame:CGRectMake(300, 200, 100, 100)];
   black.backgroundColor = [UIColor redColor];
    [self.view addSubview:black];

    UILabel *userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, 600, 300)];
    userNameLabel.text = @"你妹的";
    userNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold"size:100];
    [self.view addSubview:userNameLabel];

}









@end
